<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>编码</title>
    <!--引入Google Map JS文件，此处key＝“你申请道德key”-->
    <script type="text/javascript" src="http://ditu.google.cn/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAira30FR5tVprWCJ-8_WcqxSrc1zAT9YCtP2kOyoD7kBAJfliJBROJEdu9hUE13rp9a4OHneyOoW5gg"></script>

    <script type="text/javascript">
      //initMap()函数，将地图程序加入页面
      function initMap() {
        //GBrowserIsCompatible()确定Api能否兼容当前浏览器
        if (GBrowserIsCompatible()) {
          //在ID为"Gmap"的层内显示地图
          var map = new GMap2(document.getElementById("Gmap"));    
          //设置地图中心点和缩放级别
          map.setCenter(new GLatLng(36.07248, 120.32842), 13);
          //加载大“鱼骨”，包含方向按钮和缩放级别控制滑块
          map.addControl(new GLargeMapControl());
          //加载地图类型按钮
          map.addControl(new GMapTypeControl());
          //加载小地图
          map.addControl(new GOverviewMapControl());
          //加载比例尺
          map.addControl(new GScaleControl());
          //编码
          polyline  = new GPolyline.fromEncoded({
            color: "#FF6600",
            weight: 3,
            opacity: 0.9,
            /*
            未编码的折点数据：
            new GLatLng(36.066570000000006,120.30366000000001),
            new GLatLng(36.05875,120.32037000000001),
            new GLatLng(36.072480000000006,120.32842000000001),
            new GLatLng(36.079930000000004,120.35917)
            */
            points: "agc{E{xg}Uzo@mgBytAiq@qm@e_E",//折点编码
            zoomFactor: 32,//levels字符串中邻近缩放级别集合之间的放大倍率
            levels: "BBBB",//缩放级别编码
            numLevels: 4 //levels字符串中包含的缩放级别数
          }); 
         map.addOverlay(polyline);
       }
     }
    </script>
  </head>
  <body onload="initMap()" onunload="GUnload()">
    <!--定义显示地图的层-->
    <div id="Gmap" style="width: 600px; height: 400px"></div>
  </body>
</html>
